package com.shengyin.ec.model.entity;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

/**
 * Users entity. @author MyEclipse Persistence Tools
 */

@Entity
@Table(name="users")
public class Users extends BaseEntity implements java.io.Serializable {

	// Fields

	private Integer enable;
	private String password;
	private String account;
	
	@ManyToMany(fetch=FetchType.EAGER)
	private Set<Roles> roles = new HashSet<Roles>(0);
	
	// Constructors

	/** default constructor */
	public Users() {
	}

	// Property accessors


	public Integer getEnable() {
		return this.enable;
	}


	public Set<Roles> getRoles() {
		return roles;
	}

	public void setRoles(Set<Roles> roles) {
		this.roles = roles;
	}

	public void setEnable(Integer enable) {
		this.enable = enable;
	}

	public String getPassword() {
		return this.password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getAccount() {
		return this.account;
	}

	public void setAccount(String account) {
		this.account = account;
	}

	public Object[] getRolenames() {
		ArrayList<String> rolenames=new ArrayList<String>();
		for(Roles role:roles){
			rolenames.add(role.getName());
		}
		return rolenames.toArray();
	}

}